#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;

#define in read()
#define pii pair<int,int>
#define fi first
#define se second
#define FILE(x) freopen(x".in","r",stdin);\
	freopen(x".out","w",stdout);
#define pb push_back

int read(){
	int x = 0,sgn = 1;char ch = getchar();
	for(;!isdigit(ch);ch = getchar()) if(ch == '-') sgn = -1;
	for(;isdigit(ch);ch = getchar()) x = (x<<1)+(x<<3)+(ch^48);
	return x*sgn;
}

const int N = 1e5+10;

int phi[N],n,prime[N],pnum,m;
ll s[N],ans;
bool v[N];

void shai(){
	phi[1] = 1;
	for(int i = 2;i < N;i++){
		if(!v[i]) phi[i] = i - 1,prime[++pnum] = i;
		for(int j = 1,x;j <= pnum && prime[j] * i < N;j++){
			v[x = prime[j] * i] = 1; phi[x] = phi[i] * phi[prime[j]];
			if(i % prime[j] == 0) {
				phi[x] = phi[i] * prime[j];
				break;
			}
		}
	}for(int i = 1;i < N;i++) s[i] = s[i-1] + phi[i];
}

int main (){
#ifndef ONLINE_JUDGE
	freopen("1.in","r",stdin);
#endif
	n = in,m = in;shai();
	if(n > m) swap(n,m);
	for(int l = 1,r;l <= n;l=r+1){
		r = min(n/(n/l),m/(m/l));
		ans += (s[r] - s[l-1]) * (n / l) * (m / l);
	}
	ans = ans * 2 - 1ll * n * m;
	printf("%lld\n",ans);
	return 0;
}

